/*
 * @Author: your name
 * @Date: 2021-02-22 10:33:39
 * @LastEditTime: 2021-03-06 15:21:39
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /shb-fe-pc/server/routes/userReportCustom.js
 */
const KoaRouter = require('koa-router')
const HttpClient = require('../util/HttpClient')
const Template = require('../util/Template')

const router = new KoaRouter();
const modules = require('../../modules');

router.get('/stats/staff/personTaskReport', async ctx => {
  let script = ['/personTaskReport.list.js'];
  let modConfig = modules['personTaskReport.list'];
  let reqHeaders = ctx.request.headers;
  let result = await HttpClient.request('/stats/staff/personTaskReport', 'get', null, { headers: reqHeaders });
  let body = result.body;

  ctx.body = await Template.renderWithHtml('人员工单报表', body, script, modConfig.template, ctx)
});

router.get('/stats/staff/financeStatisticsReport', async ctx => {
  let script = ['/financeStatisticsReport.list.js'];
  let modConfig = modules['financeStatisticsReport.list'];
  let reqHeaders = ctx.request.headers;
  let result = await HttpClient.request('/stats/staff/financeStatisticsReport', 'get', null, {headers: reqHeaders});
  let body = result.body;
  
  ctx.body = await Template.renderWithHtml('财务报表', body, script, modConfig.template, ctx)
});

router.get('/stats/staff/personFinanceReport', async ctx => {
  let script = ['/personFinanceReport.list.js'];
  let modConfig = modules['personFinanceReport.list'];
  let reqHeaders = ctx.request.headers;
  let result = await HttpClient.request('/stats/staff/personFinanceReport', 'get', null, {headers: reqHeaders});
  let body = result.body;
  
  ctx.body = await Template.renderWithHtml('人员财务信息', body, script, modConfig.template, ctx)
});

module.exports = router;